import requests
import logging

class Test1():
    uid=""
    sid=""
    def setup_method(self):
        print("初始化环境")
    def teardown_method(self):
        print("恢复环境")

    #登录
    def test_dl(self):
        try:
            url="http://10.59.9.18/small/user/v1/login"
            body={"phone":"13811033965","pwd":"123456Aa"}
            headers={"Content-Type":"application/json"}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
            Test1.uid = r.json()["result"]["userId"]
            Test1.sid = r.json()["result"]["sessionId"]
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200

    #新增收货地址正例
    def test_xzshdz(self):
        try:
            url="http://10.59.9.18/small/user/verify/v1/addReceiveAddress"
            body={"realName":"李先生","phone":"18626407589","address":"北京 海淀区 八维","zipCode":"101010"}
            headers={"userId":int(Test1.uid),"sessionId":Test1.sid}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200

    # 新增收货地址反例
    def test_xzshdz1(self):
        try:
            url="http://10.59.9.18/small/user/verify/v1/addReceiveAddress"
            body={"realName":"李先生","phone":"18626407589","address":"北京 海淀区 八维","zipCode":"101010"}
            headers={"userId":"int(Test1.uid)","sessionId":"Test1.sid"}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200

    # 新增收货地址反例
    def test_xzshdz2(self):
        try:
            url="http://10.59.9.18/small/user/verify/v1/addReceiveAddress"
            body={"realName":"李先生","phone":"18626407589","address":"北京 海淀区 八维","zipCode":"101010"}
            headers={"userId":"","sessionId":Test1.sid}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200

    # 新增收货地址反例
    def test_xzshdz3(self):
        try:
            url="http://10.59.9.18/small/user/verify/v1/addReceiveAddress"
            body={"realName":"李先生","phone":"18626407589","address":"北京 海淀区 八维","zipCode":"101010"}
            headers={"userId":int(Test1.uid),"sessionId":""}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200

    # 新增收货地址反例
    def test_xzshd4(self):
        try:
            url="http://10.59.9.18/small/user/verify/v1/addReceiveAddress"
            body={"realName":"李先生","phone":"18626407589","address":"北京 海淀区 八维","zipCode":"101010"}
            headers={"userId","sessionId"}
            r=requests.post(url=url,json=body,headers=headers)
            print(r.json())
        except Exception as e:
            logging.info(e)
        assert r.status_code == 200



